<html>
<head><meta charset="utf-8"><title>Fallible `Vec` · t-libs/wg-allocators · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/index.html">t-libs/wg-allocators</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html">Fallible `Vec`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="179651941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Fallible%20%60Vec%60/near/179651941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Erich Gubler <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html#179651941">(Nov 01 2019 at 18:33)</a>:</h4>
<p>Hmm, so, I have two concerns after taking some initial work making allocation-fallible APIs for <code>Vec</code>:</p>
<ul>
<li>The awesome <code>splice</code> API gets rather complicated because it finalizes splicing operations once the return value of <code>splice</code> (a <code>Splice</code> struct) gets <code>drop</code>ped. <code>Drop</code> isn't changing any time soon, so there needs to be something separate for finalization. Perhaps the best solution is to panic when a finalization wasn't attempted before <code>Drop</code>? @Simon Sapin, I want to hear what you think about this too.</li>
</ul>



<a name="179657301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Fallible%20%60Vec%60/near/179657301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Erich Gubler <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html#179657301">(Nov 01 2019 at 19:32)</a>:</h4>
<ul>
<li>There are some places I've noticed where naively converting the old implementation over to simply use the fallible API and otherwise reuse the bodies of the infallible versions might result in some problems with invariants not being maintained. Not a hard problem, but needs some good eyes in review. :)</li>
</ul>



<a name="179665926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Fallible%20%60Vec%60/near/179665926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html#179665926">(Nov 01 2019 at 21:08)</a>:</h4>
<p>Two good points, I'll take a look :)</p>



<a name="179749411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Fallible%20%60Vec%60/near/179749411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html#179749411">(Nov 03 2019 at 14:25)</a>:</h4>
<p>Regarding your first Dot, do you have problems implementing <code>Drop</code> on <code>Splice</code> itself? Do you have a code sample pushed anywhere?</p>



<a name="182123467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Fallible%20%60Vec%60/near/182123467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html#182123467">(Nov 28 2019 at 17:02)</a>:</h4>
<p>Oops, only seeing this now. Using a space a good way to spell my full name but not to @mention my username :)<br>
A few thoughts:</p>



<a name="182123905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Fallible%20%60Vec%60/near/182123905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html#182123905">(Nov 28 2019 at 17:09)</a>:</h4>
<ul>
<li>Fallible API are not tied to allocator-generic contains, so I’m not sure they’re in scope for this WG. Feel free to file issues on rust-lang/rust for standard library API discussion, or RFCs if there’s a lot non-trivial design involved</li>
<li>I’m not sure how much appetite there is to basically double the API surface for standard library containers. It’s hard enough to make progress on just <code>try_reserve</code>. Just because an infallible API exists doesn’t mean a corresponding fallible API should be added, especially if it’s a convenience thing that can be achieved with a sequence of calls to other APIs</li>
<li>For things that <em>are</em> added, I’m not surprised that complex cases require more surface changes than just returning <code>Result</code>. <code>Drop</code> could be just one case of this</li>
</ul>



<a name="182123974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Fallible%20%60Vec%60/near/182123974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Fallible.20.60Vec.60.html#182123974">(Nov 28 2019 at 17:10)</a>:</h4>
<p><span class="user-mention" data-user-id="220097">@Erich Gubler</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>